package br.edu.unibratec.Projeto.view;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Point;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.GeoPoint;

;

public class MyOverlay extends Overlay {

	private Bitmap imagem;
	private GeoPoint geoPoint;

	public MyOverlay(Bitmap imagem) {
		super();
		this.imagem = imagem;
	}

	public void setGeoPint(GeoPoint geoPoint) {
		this.geoPoint = geoPoint;
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		super.draw(canvas, mapView, shadow);

		if (geoPoint != null) {
			Point pontoMapa = mapView.getProjection().toPixels(geoPoint, null);
			canvas.drawBitmap(imagem, pontoMapa.x - (imagem.getWidth() / 2),
					pontoMapa.y - (imagem.getHeight()), null);
		}

	}
}
